<?php
namespace Mobile\Controller;
use Think\Controller;
class SeadController extends Controller {
    public function index(){

        //根据的id
        //生产订单所需要的数据
        $_SESSION['mobile']['data']=$_GET;
        //放映时间
       $time2= $_SESSION['mobile']['data']['ftime'];
        $timeday =time();  //当前时间搓
        $time4= date('Ymd',$time2 )-date('Ymd',$timeday );
        //播放日期
        $time11=date('(m月d日) H:i',$time2);
        if($time4==0){
            $this->assign('message','今天');
            $this->assign('time11',$time11);
            $this->assign('language',$_SESSION['mobile']['data']['yy']);//语言
        }else if($time4==1){
            $this->assign('message','明天');
            $this->assign('time11',$time11);
            $this->assign('language',$_SESSION['mobile']['data']['yy']);//语言
        }else if($time4==2){
            $this->assign('message','后天');
            $this->assign('time11',$time11);
            $this->assign('language',$_SESSION['mobile']['data']['yy']);//语言
        }
        //电影的名字
        $movieid = $_SESSION['mobile']['mid'];
        $movielist = M('movie')->where('id='.$movieid)->find();
        $_SESSION['mobile']['data']['moviename']=$movielist['name'];
        //发送电影的名字
        $this->assign('moviename', $_SESSION['mobile']['data']['moviename']);

        //发送座位多少个
        //电影项的id
        $rid = $_SESSION['mobile']['data']['rid'];
        $roo_sead = M('room_seat');
        $roo_seads = $roo_sead->where('room_id='.$rid)->select();

            $loss = json_encode(explode(',',$roo_seads[0]['loss']));
            $this->assign('loss', $loss);
        $this->assign('roo_seads', $roo_seads);
        $this->display();
    }

    //ajax 请求是否有座位被选中
    public function sellAjax(){
           if(!empty($_POST['name'])){
               $screening_id =$_POST['name'] ;
               //查询该场次次向里面 是否有座位被选中了
               $item = M(orderItem);
               $itemList = $item->where('screening_id='.$screening_id)->select();
               foreach($itemList as $key=>$val){
                   $row[$key]['row'] = explode(',', $val['seat_row']);//行
                   $col[$key]['col'] = explode(',', $val['seat_column']);//列
                   for ($i = 0; $i < count($row[$key]['row']); $i++) {
                       $seat[$key][$i]['row'] = $row[$key]['row'][$i];
                       $seat[$key][$i]['col'] = $col[$key]['col'][$i];
                   }
               }
               echo json_encode($seat);
           }else{
                echo 0;
            }
    }





}